Skip to content

Version handling: Maven versions, ranges, no pre-releases, errors are reported - #11

Merged
GianTschingt merged 2 commits into
lucee:mainfrom
GianTschingt:version-handling
Nov 17, 2026
Merged

GianTschingt merged 2 commits into
lucee:mainfrom
GianTschingt:version-handling

Conversation

@GianTschingt

Copy link
Copy Markdown
Contributor

Builds on #10 (Felix configuration), this branch contains that commit as well, review/merge #10 first. The change of this PR is the second commit.

Version handling in the bundle resolver:

  • BundleProvider.toVersion accepts the Maven spelling of a version: 33.8.0-jre becomes 33.8.0.jre, 2.17 becomes 2.17.0, 3.0-rc5 becomes 3.0.0.rc5. Before, 33.8.0-jre failed with For input string: "0-jre".
  • getBundleAsURL tries the version as given first (the Maven spelling, 33.8.0-jre), then the OSGi spelling, and 2.17 for 2.17.0. Before, it only used the OSGi spelling (33.8.0.jre), which does not exist on Maven.
  • latestVersion(name, range) reads all versions from maven-metadata.xml and returns the newest one inside the range. Pre-releases (rc, alpha, beta, snapshot, milestones like M1, ea, preview, ...) are skipped unless the range itself asks for one. Before, it returned <release>/<latest>, which is 3.0-rc5 for jackson-annotations. It now throws with the reason for each repository instead of returning null when the bundle is mapped but nothing fits.
  • A missing bundle or package from a failed start keeps the whole range of the requirement, (bundle-version>=2.17.0)(!(bundle-version>=99.0.0)) is [2.17.0,99.0.0) and not the exact version 2.17.0. The newest installed or local bundle inside the range is used (bundle directory and the additional directories) before anything is downloaded. Bundles found in the bundle directory for a missing package must also export the package in a version inside the range.
  • The errors from loading the missing dependencies are no longer swallowed, they are part of the exception (failed to load what is missing: ...).
  • Should-fix items: downloads have a read timeout, a download goes to a unique temp file (two threads downloading the same bundle no longer write into the same file), and the readers cache is a ConcurrentHashMap.
  • Package mappings for com.fasterxml.jackson.core, com.fasterxml.jackson.databind and com.google.common.util.concurrent.internal (guava failureaccess), and a package is mapped to a bundle with the same name when there is one (like com.google.gson).

Local results, the tests from #9, with a 9.0 core that has lucee/Lucee#3816 (LDEV-6948):

With 9.0.0.1487-ALPHA all of them pass except "is actually active". The core tests with the label osgi from 9.0 with lucee/Lucee#3816 pass as well with the extension installed (OSGiExtensions, RemovedBundles, ShadedAsm, VersionImpl, LDEV6948).

CI on main needs a core with lucee/Lucee#3816 before "is actually active" can pass.

@CLAassistant

CLAassistant commented Nov 16, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@GianTschingt

Copy link
Copy Markdown
Contributor Author

@cla-assistant[bot] check

@michaeloffner

Copy link
Copy Markdown
Contributor

Review of the version handling (read the diff, did not run it).

Overall: the approach is right. It fixes the real causes (Maven spelling in toVersion and getBundleAsURL, <release>/<latest> in latestVersion, the range reduced to its lower bound in loadMissing), and the errors are now reported. Findings, most important first:

  1. loadMissing package fallback loads an out-of-range bundle (catch (IOException e) { if (range == null) throw e; load(bundle, (VersionRange) null, dirs); }). If nothing fits the range, it loads any version, and latestVersion(name, null) returns the newest release, for example a 3.x for a [2.17,3) requirement. That is the wrong-version problem again, and the failure shows up later as a different, harder to read resolve error. The bundle of a package does not always have the version of the package. I would drop the fallback, or accept it only when the package version of the loaded bundle is inside the range (you already parse Export-Package in findExporting).
  2. Unmapped bundles still use the lower bound as the exact version (version = toLucee(range.getLeft()) when latestVersion returns null). It is a documented guess, but it is the >=X is exact X bug for every bundle that is not in osgi-maven-mapping.ini. Please add a test or at least a comment that this stays a limitation. If the left side is open ((1.0,2.0)) version stays null and download(name, null) is called, please check that this fails with a readable message.
  3. isPreRelease can match real releases. The qualifier list contains the single letters a, b, m, pre and dev, so a qualifier like .b or -m is skipped as a pre-release. It is rare, but for a final release it silently narrows the candidates. A test table with positive and negative cases (jre, android, Final, RELEASE, sp1, v20230101, M1, Beta2, rc5) would pin this down.
  4. Guava flavours: 33.8.0-jre and 33.8.0-android both parse to 33.8.0.<qualifier> and are ordered by the qualifier string. jre wins over android only because j > a. It works by accident. If the requested raw version has a flavour, only versions with the same flavour should be considered.
  5. toVersion changes the spelling of qualifiers (1.2.3.4.5 becomes 1.2.3.4_5), and an all-digit overflow (20030203.000129) returns the default silently. Fine for latestVersion (the entry is skipped), but matches(...) compares with the parsed form, so two different Maven versions could compare equal. Low risk.
  6. addFelixDefaults (from Felix reads its own default.properties, not the one of the Lucee core #10) says system properties still win, but only config.containsKey is checked. A -Dorg.osgi.framework.system.packages=... is ignored once the key is in the config map. Please check which one Felix prefers; if Felix reads the config map first, the claim in the code comment is wrong.
  7. findJar(dir, name, range) plus the dirs loop reads the manifest of the same jar repeatedly (read(candidate) and read(jar) inside the loop). Keep the version of the best jar in a variable, like findJar already does.
  8. Tests changed in Felix reads its own default.properties, not the one of the Lucee core #10: the edits to tests/OSGiExtension.cfc (info[ "state" ], clazz.newInstance(), array arguments for invoke) are test bugs, not hidden failures, so OK. This PR still contains them (it is stacked on the merged Felix reads its own default.properties, not the one of the Lucee core #10), so a rebase on main before merging will make the diff smaller.
  9. Missing tests: toRange ((version>=2.17.0)(!(version>=3.0.0)), <=, (!(version<=X)), =), getMavenVersions and isPreRelease are pure functions and easy to unit test. The existing CFML tests only cover the three bundles from Add tests that catch known OSGi service and Felix/version bugs #9.

CI: no test job is shown for this PR so far, so I could not confirm the results from the description. "is actually active" needs a Lucee 9 build with lucee/Lucee#3816, which is not published yet (the newest one on maven.lucee-services.com is still 9.0.0.1487-ALPHA).

… reported

- toVersion accepts the Maven spelling of a version (33.8.0-jre, 2.17, 3.0-rc5)
- getBundleAsURL tries the version as given first, then the OSGi spelling and
  2.17 for 2.17.0
- latestVersion only returns a version inside the range and skips
  pre-releases (rc, alpha, beta, snapshot, milestones, ...) unless the range
  asks for one; it throws with the reason instead of returning null
- a missing bundle or package keeps the whole range of the requirement
  (bundle-version>=X is not the exact version X), the newest local match is used
  before anything is downloaded
- when the dependencies cannot be loaded, the reasons are part of the exception
- downloads have a read timeout and use a unique temp file, the readers cache is
  a ConcurrentHashMap
- packages of jackson-core, jackson-databind and guava failureaccess are mapped
  to their bundles, and a package is mapped to a bundle with the same name
- drop the null-range fallback in loadMissing, so a package range cannot
  load an out-of-range bundle; local jars still have to export the package
  in range
- latestVersion only considers the same flavour (jre or android) when the
  range asks for one
- add unit tests for isPreRelease, toRange, getMavenVersions, flavour and
  the unmapped lower-bound limitation; the isPreRelease table has no false
  positives, so the regex is unchanged
- document toVersion extra segments and overflow, and point addFelixDefaults
  at the system-property override in framework()
- keep the best jar version in a variable instead of re-reading manifests
@GianTschingt

Copy link
Copy Markdown
Contributor Author

I've addressed the review comments and rebased onto main (the already-merged #10 commit is gone).

  1. Removed the null-range fallback in loadMissing. A package range can no longer load an out-of-range bundle. Local jars are still only used when findExporting confirms Export-Package is inside the range.
  2. Added a comment and a unit test for unmappedVersion: a closed lower bound is still used as the exact version for unmapped bundles; an open lower bound fails with a readable message from download().
  3. Added the isPreRelease test table (jre, android, Final, RELEASE, sp1, v20230101, M1, Beta2, rc5, …). No false positives, so the regex is unchanged.
  4. latestVersion only considers the same flavour (jre or android) when the range asks for one.
  5. Documented the toVersion cases (extra segments become 4_5, overflow returns the default) and covered them in the unit tests.
  6. Added a one-line pointer in addFelixDefaults to the system-property override in framework().
  7. The newest jar across directories keeps its version in a variable, so manifests are not read again.
  8. Rebased onto main.
  9. Added source/java/test/.../VersionHandlingTest.java (JUnit) for toRange, getMavenVersions, isPreRelease, flavour and the unmapped lower bound. All 20 tests pass locally.

What's left: the CLA check is still pending. The CFML tests still need a published Lucee 9 core with lucee/Lucee#3816 (LDEV-6948); the newest one on maven.lucee-services.com is still 9.0.0.1487-ALPHA.

@GianTschingt
GianTschingt merged commit fe977d7 into lucee:main Nov 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants